package com.example.tests;

import com.example.fw.FolderList;
import org.testng.annotations.Test;

import java.util.Random;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

/**
 * Created with IntelliJ IDEA.
 * User: pshevchenko
 * Date: 02.04.13
 * Time: 15:31
 * To change this template use File | Settings | File Templates.
 */
public class TestFolderDeletion extends TestBase {
    @Test
    public void deleteFolder(){
        FolderList oldFolderNames = applicationManager.getFolderHelper().getFolders();
        int foldersCount = oldFolderNames.size();
        if (foldersCount == 0){
            return;
        }

        int randomFolderIndex = new Random().nextInt(foldersCount);

        applicationManager.getFolderHelper().deleteFolder(oldFolderNames.get(randomFolderIndex));

        FolderList newFolderNames = applicationManager.getFolderHelper().getFolders();

        assertThat(newFolderNames, equalTo(oldFolderNames.withRemoved(randomFolderIndex)));
    }

}
